<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
    <title>个人信息</title>
    <link href="/resources/bootstrap-3.3.5-dist/css/bootstrap.min.css" title="" rel="stylesheet"/>
    <link title="" href="/resources/css/style.css" rel="stylesheet" type="text/css"/>
    <link title="blue" href="/resources/css/dermadefault.css" rel="stylesheet" type="text/css"/>
    <link href="/resources/css/templatecss.css" rel="stylesheet" title="" type="text/css"/>
    <script src="/resources/script/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="/resources/script/jquery.cookie.js" type="text/javascript"></script>
    <script src="/resources/bootstrap-3.3.5-dist/js/bootstrap.min.js" type="text/javascript"></script>
    <style>
        label {
            text-align: right;
        }

    </style>
    <script type="text/javascript">
        var insertmessage = "<%=session.getAttribute("insertmessage")%>";
        console.log(insertmessage)
        if (insertmessage == "errorRepete") {
            alert("用户已存在，请重新添加！");
        }
        if (insertmessage == "errorNull") {
            alert("数据为空，请重新填写！");
        }
    </script>
</head>

<body>
<%@ include file="head.jsp" %>
<div class="down-main">
    <%@ include file="left.jsp" %>
    <div class="right-product view-product right-full">
        <div class="container-fluid">
            <div class="info-center">
                <div class="page-header">
                    <div class="pull-left">
                        <h4><strong style="font-family: STXingkai;font-size: 30px; ">添加用户</strong></h4>
                    </div>
                    <div class="pull-right">
                        <button class=" btn btn-default btn-md btn-block" style="position: relative; margin: 10px;"
                                type="button" onclick="history.back(-1)">返回
                        </button>
                    </div>
                    <div class="pull-right">
                        <button id="addInt" class=" btn btn-info btn-md btn-block"
                                style="position: relative; margin: 10px;"
                                type="button" onclick="addUser()">提交
                        </button>
                    </div>

                </div>
                <div class="indentify-class padding-lr">
                    <div class="myform-content">
                        <form class="form-horizontal2" id="formAdd" action="/user/addUser" method="post" role="form">
                            <br/>
                            <div class="form-group formdiv row">
                                <label for="userAccount" class="col-md-2 control-label">身份证号码:</label>
                                <div class="col-md-4">
                                    <input type="text" class="form-control" id="userAccount" maxlength="18"
                                           name="userAccount" value=""
                                           placeholder="请输入身份证号码">
                                </div>
                                <label for="userName" class="col-md-2 control-label">用户姓名:</label>
                                <div class="col-md-4">
                                    <input type="text" class="form-control" id="userName" name="userName" value=${userInfo.userName}
                                           placeholder="请输入用户姓名">
                                </div>
                            </div>

                            <div class="form-group formdiv row">
                                <label class="col-md-2 control-label">用户性别:</label>
                                <div class="col-md-4">
                                    <select class="form-control" name="userSex">
                                        <option value="男">男</option>
                                        <option value="女" selected="selected">女</option>
                                    </select>
                                </div>
                                <label for="userNation" class="col-md-2 control-label">用户民族:</label>
                                <div class="col-md-4">
                                    <input type="text" class="form-control" id="userNation" name="userNation" value=""
                                           placeholder="请输入...">
                                </div>
                            </div>
                            <div class="form-group formdiv row">
                                <label for="userBirthday" class="col-md-2 control-label">出生日期:</label>
                                <div class="col-md-4">
                                    <input type="date" class="form-control" id="userBirthday" name="userBirthday"
                                           value="" pattern="yyyy-MM-dd">
                                </div>
                                <label for="userEducation" class="col-md-2 control-label">用户学历:</label>
                                <div class="col-md-4">
                                    <input type="text" class="form-control" id="userEducation" name="userEducation"
                                           value="" placeholder="请输入...">
                                </div>
                            </div>
                            <div class="form-group formdiv row">
                                <label for="userWork" class="col-md-2 control-label">工作岗位:</label>
                                <div class="col-md-4">
                                    <input type="text" class="form-control" id="userWork" name="userWork" value=""
                                           placeholder="请输入....">
                                </div>
                                <label for="userType" class="col-md-2 control-label">人员类别:</label>
                                <div class="col-md-4">
                                    <select class="form-control" id="userType" name="userType">
                                        <option value="正式党员">正式党员</option>
                                        <option value="预备党员">预备党员</option>
                                        <option value="入党积极分子">入党积极分子</option>
                                        <option value="发展对象">发展对象</option>
                                        <option value="入党申请人" selected="selected">入党申请人</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group formdiv row">
                                <label for="userBranch" class="col-md-2 control-label">所在党支部:</label>
                                <div class="col-md-4">
                                    <select class="form-control" id="userBranch" name="userBranch">
                                        <c:forEach var="partyLevel" items="${partyLevleList}">
                                            <option value="${partyLevel.title}">${partyLevel.title}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                                <label for="userDuty" class="col-md-2 control-label">担任职务:</label>
                                <div class="col-md-4">
                                    <select class="form-control" id="userDuty" name="userDuty">
                                        <option value="无" selected="selected">无</option>
                                        <option value="教职工党支部">书记</option>
                                        <option value="学生党支部">组织委员</option>
                                    </select>
                                </div>
                            </div>
                            <div class=" form-group formdiv row">
                                <label for="userPhone" class="col-md-2 control-label">联系电话:</label>
                                <div class="col-md-4">
                                    <input type="text" class="form-control" id="userPhone" name="userPhone" value=""
                                           placeholder="请输入....">
                                </div>
                                <label for="userAddress" class="col-md-2 control-label">家庭住址:</label>
                                <div class="col-md-4">
                                    <input type="text" class="form-control" id="userAddress" name="userAddress" value=""
                                           placeholder="请输入...">
                                </div>
                            </div>
                            <div class="form-group formdiv row">
                                <label for="userStatus" class="col-md-2 control-label">党籍状态:</label>
                                <div class="col-md-4">
                                    <select class="form-control" id="userStatus" name="userStatus">
                                        <option value="无" selected="selected">无</option>
                                        <option value="正常">正常</option>
                                        <option value="出党">出党</option>
                                        <option value="停止党籍">停止党籍</option>
                                        <option value="死亡">死亡</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group formdiv row">
                                <label for="userMiss" class="col-md-2 control-label">是否为失联党员:</label>
                                <div class="col-md-4">
                                    <select class="form-control" id="userMiss" name="userMiss">
                                        <option value="1">是</option>
                                        <option value="0" selected="selected">否</option>
                                    </select>
                                </div>
                                <label for="userFlow" class="col-md-2 control-label">是否为流动党员:</label>
                                <div class="col-md-4">
                                    <select class="form-control" id="userFlow" name="userFlow">
                                        <option value="1">是</option>
                                        <option value="0" selected="selected">否</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group formdiv row">
                                <label for="userPwd" class="col-md-2 control-label">新密码:</label>
                                <div class="col-md-4">
                                    <input type="password" class="form-control" id="userPwd" name="userPwd" value=""
                                           placeholder="请输入新密码">
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        /*左侧导航栏显示隐藏功能*/
        $(".subNav").click(function () {
            /*显示*/
            if ($(this).find("span:first-child").attr('class') == "title-icon glyphicon glyphicon-chevron-down") {
                $(this).find("span:first-child").removeClass("glyphicon-chevron-down");
                $(this).find("span:first-child").addClass("glyphicon-chevron-up");
                $(this).removeClass("sublist-down");
                $(this).addClass("sublist-up");
            }
            /*隐藏*/
            else {
                $(this).find("span:first-child").removeClass("glyphicon-chevron-up");
                $(this).find("span:first-child").addClass("glyphicon-chevron-down");
                $(this).removeClass("sublist-up");
                $(this).addClass("sublist-down");
            }
            // 修改数字控制速度， slideUp(500)控制卷起速度
            $(this).next(".navContent").slideToggle(300).siblings(".navContent").slideUp(300);
        })
        /*左侧导航栏缩进功能*/
        $(".left-main .sidebar-fold").click(function () {

            if ($(this).parent().attr('class') == "left-main left-full") {
                $(this).parent().removeClass("left-full");
                $(this).parent().addClass("left-off");

                $(this).parent().parent().find(".right-product").removeClass("right-full");
                $(this).parent().parent().find(".right-product").addClass("right-off");

            } else {
                $(this).parent().removeClass("left-off");
                $(this).parent().addClass("left-full");

                $(this).parent().parent().find(".right-product").removeClass("right-off");
                $(this).parent().parent().find(".right-product").addClass("right-full");

            }
        })

        /*左侧鼠标移入提示功能*/
        $(".sBox ul li").mouseenter(function () {
            if ($(this).find("span:last-child").css("display") == "none") {
                $(this).find("div").show();
            }
        }).mouseleave(function () {
            $(this).find("div").hide();
        });


    })
    /**
     * 校验文本是否为空
     * tips：提示信息
     * 使用方法：$("#id").validate("提示文本");
     * @itmyhome
     */
    $.fn.validate = function (tips) {
        if ($(this).val() == "" || $.trim($(this).val()).length == 0) {
            alert(tips + "不能为空！");
            throw SyntaxError(); //如果验证不通过，则不执行后面
        }
    }

    //提交表单
    function addUser() {
        //调用validate()
        $("#userAccount").validate("账号");
        $("#userPwd").validate("密码");
        $('#formAdd').submit();
    }
    //数据库备份
    function databasebackup() {
        if (confirm("请确认操作")) {
            $.ajax({
                url: '/databasebackup',
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    if (data.errno == 0) {
                        alert(data.message);
                        location.reload()
                    } else {
                        alert(data.message);
                    }
                }
            });
        } else {
            location.reload()
        }
    }
</script>
</body>
</html>
